package net.wwang.open.dao;

import net.wwang.open.pojo.Document;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author WangWei
 * @date 2020/8/11
 */
public interface DocumentDao extends JpaRepository<Document, String>, JpaSpecificationExecutor<Document> {
	List<Document> findDocumentsByTitle(String title);

	Document findDocumentByMenuId(String menuId);

	void deleteDocumentByMenuId(String menuId);

	@Query(nativeQuery = true, value = "select `content` from `document` where `menu_id` in (:ids)")
	List<String> findDocumentsByIds(@Param("ids") List<String> ids);
}
